/**
 * Created by wz .
 * description:
 **/
import { HTTP } from '../util/http'

class Login extends HTTP {
  code2Session(params = {}, success) {
    let url = 'Lib/phone/GetOpenidAndAccessTokenFromCode'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  getAESDecrypt(params = {}, success) {
    let url = 'Lib/phone/PostAESDecrypt'
    let data = params
    this.request({
      url: url,
      method: 'POST',
      data: data,
      oldURL: true,
      urlData: {
        rnd: 123
      },
      success
    })
  }

  getAddWXUser(params = {}, success) {
    let url = 'Lib/GetAddWXUserForShare'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  GetSMSCode(params = {}, success, fail) {
    let url = 'Lib/GetSMSCode'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success,
      fail
    })
  }

  GetUserQuickLogin(params = {}, success) {
    let url = 'UserBase/GetUserQuickLogin'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  GetUserLogin(params = {}, success) {
    let url = 'UserBase/GetUserLogin'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  GetMyDistributionYard(success) {
    let url = 'UserBase/GetMyDistributionYard'
    let data = {
      user_id: wx.getStorageSync('userInfo').user_id
    }
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  Get24HoursTo(params = {}, success) {
    let url = 'HomePage/Get24HoursTo'
    let data = params
    this.request({
      url: url,
      data: data,
      oldURL: true,
      success
    })
  }

  getUserToken(params = {}, success) {
    let url = 'user/queryUserToken'
    let data = params
    this.request({
      url: url,
      data: data,
      success,
      method: 'POST'
    })
  }

  giveShareLoginAward(params = {}, success) {
    // 赠送分享登录奖励
    let url = 'user/giveShareLoginAward'
    let data = Object.assign({}, params, {
      userId: wx.getStorageSync('userInfo').user_id || 0
    })
    this.request({
      url: url,
      data: data,
      success
    })
  }
}

export { Login }
